# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=cdparanoia
pkgver=10.2
pkgrel=14
pkgdesc="An audio CD extraction application"
url="https://www.xiph.org/paranoia"
arch="all"
options="!check"  # Build system has test suite commented out.
license="GPL-2.0-or-later"
makedepends="libtool autoconf automake linux-headers"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="https://downloads.xiph.org/releases/cdparanoia/cdparanoia-III-$pkgver.src.tgz
	format-security.patch
	gcc.patch
	fix-includes.patch"
builddir="$srcdir/$pkgname-III-$pkgver"

prepare() {
	default_prepare
	mv configure.guess config.guess
	mv configure.sub config.sub
	update_config_sub
	sed -i -e '/configure.\(guess\|sub\)/d' configure.in
	aclocal && autoconf
	libtoolize
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make -j1
}

package() {
	make prefix="$pkgdir"/usr MANDIR="$pkgdir"/usr/share/man install
}

libs() {
	pkgdesc="Libraries for libcdda_paranoia (Paranoia III)"
	license="LGPL-2.1-or-later"
	replaces="cdparanoia"
	install -d "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

sha512sums="
4ab0a0f5ef44d56c1af72d1fc1035566a1a89c4eeddb9e8baea675fe51c06138d913342afc8bed167d9fa55672fa25a2763ce21f7e24c1232e4739aff20733a7  cdparanoia-III-10.2.src.tgz
be88cbe9fb611e56eb180de15422b31436226728246397f8460ea56444ea59537efdcde39ffee170ea8d6cf1784ec71df98c1a65c436f7e59a1057e952384a1c  format-security.patch
27bf216e8b5b9d6971e3999166544025f166587df06065b89657dac62d0d53c01b76f53146c1e9a400dd71460567fadb8fd4ce00576836f972914d69e8855909  gcc.patch
e8a5ef0f5bcdba697d2d49e31346832bfa2460e6f6cac9256420f57c74a5da2945bdc664368c91365a880ba76e638f58773468d8e8bd16e7afcaff955a1a82ce  fix-includes.patch
"
